<%@ taglib prefix="his_fns" uri="http://java.sun.com/jsp/jstl/functionss" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<script type="text/javascript">
    function page(n, s) {
        $("#pageNo").val(n);
        $("#pageSize").val(s);
        btsubmit();
        return false;
    }
    function btsubmit() {
        var form = $("#searchForm");
        if ($("#batch").is(':checked')) {
//            $("#batchNo").hide();
//            $("#expireDate").hide();
//            $("#batchNo1").hide();
//            $("#expireDate1").hide();
            form.attr("onsubmit", "return loadDivForm('mainCenterDiv','searchForm','${ctx}/drug/drugStock/queryAll');")
        } else {
            form.attr("onsubmit", "return loadDivForm('mainCenterDiv','searchForm','${ctx}/drug/drugStock/queryAllBat');")
        }
        form.submit();
    }
</script>
<div class="content-wrap">
    <div class="wrapper" style="bottom: 50px;">
        <ul class="nav nav-tabs">
            <li class="active">
                <a href="#" onclick="loadDiv('mainCenterDiv','${ctx}/drug/drugStock/queryAllBat')">全院库存量列表</a>
            </li>
        </ul>
        <section class="panel panel-default">
            <div class="panel-body">
                <div class="table-responsive no-border">
                    <div class="datatable-top">
                        <div class="pull-left">
                            <form:form id="searchForm" modelAttribute="drugStock" onsubmit="" method="post"
                                       class="form-inline">
                                <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                                <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
                                <label>药品类别:</label>
                                <sys:treeselect selectedParent="false" id="drugType" name="drugType"
                                                value="${drugStock.drugType}"
                                                update="${not empty drugType}" labelName="drugType1"
                                                labelValue="${drugStock.drugNameDict.drugClassDict.className}"
                                                title="药品类别"
                                                url="/drug/drugClassDict/treeData" extId="${drugStock.id}"
                                                cssClass="form-control"/>
                                <label>药品名称：</label><form:input path="drugName" htmlEscape="false" maxlength="50"
                                                                class="form-control"/>
                                <label>库存单位：</label><form:select path="storageId" name="storageId" htmlEscape="false"
                                                                 maxlength="50" class="form-control">
                                <form:option value=""></form:option>
                                <form:option value=""></form:option>
                                <c:forEach items="${list}" var="drugStorageDept">
                                    <form:option
                                            value="${drugStorageDept.id}">${drugStorageDept.storageName}</form:option>
                                </c:forEach>
                            </form:select>
                                <label>供应商：</label><form:select path="drugSupplierCata.id" htmlEscape="false"
                                                                maxlength="50" class="form-control">
                                <form:option value=""></form:option>
                                <form:option value=""></form:option>
                                <c:forEach items="${firmList}" var="drugSupplierCata">
                                    <form:option
                                            value="${drugSupplierCata.id}">${drugSupplierCata.supplierName}</form:option>
                                </c:forEach>
                            </form:select><br>
                                <label>合并批号：</label><form:checkbox path="batch" id="batch"
                                                                   htmlEscape="false"></form:checkbox>
                                <input id="btnSubmit" class="btn btn-primary" type="button" value="查询"
                                       onclick="btsubmit()"/>
                            </form:form>
                        </div>
                    </div>
                    <table id="contentTable" class="table table-bordered table-striped mg-t datatable">
                        <thead>
                        <tr>
                            <th>药品名称</th>
                            <%--<th>库存单位</th>--%>
                            <%--<th>包装数量</th>--%>
                            <th>包装规格</th>
                            <th>包装单位</th>
                            <th>厂商</th>
                            <%--<th>最小规格</th>--%>
                            <%--<th>最小单位</th>--%>
                            <th id="batchNo">批号</th>
                            <th id="expireDate">有效期</th>
                            <th>大包装库存量</th>
                            <th>小包装库存量</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${page.list}" var="drugStock">
                        <tr>
                            <td> ${drugStock.drugName}</td>
                                <%--<td> ${drugStock.storageId}</td>--%>
                                <%--  <td> ${drugStock.packageNum}</td>--%>
                            <td> ${drugStock.packageSpec}</td>
                            <td> ${fns:getDictLabel(drugStock.packageUnits,'SPEC_UNIT','')}</td>
                            <td> ${drugStock.firmName}</td>

                                <%--<td> ${drugStock.minSpec}</td>--%>
                                <%--<td> ${drugStock.minUnits}</td>--%>
                            <td id="batchNo1"> ${drugStock.batchNo}</td>
                            <td id="expireDate1"><fmt:formatDate value="${drugStock.expireDate}"
                                                                 pattern="yyyy-MM-dd"/></td>
                            <td> ${drugStock.quantity/drugStock.packageNum}</td>
                            <td> ${drugStock.quantity}</td>
                        </tr>
                        </c:forEach>
                    </table>
                    <div class="pagination">${page}</div>
                </div>
            </div>
        </section>
    </div>
</div>